#@layout()
#define script()
<script>
    $('#form').on('submit', function () {
        ajaxSubmit('#form',function () {
            location.href = "#(CPATH)/admin/article/banner";
        })
        return false;
    });

    $('.del-action').on('click', function () {
        var id = $(this).attr("data-id");
        ajaxGet("#(CPATH)/admin/article/doBannerDel/" + id);
    });

    $('.addtomenu-action').on('click', function () {
        var id = $(this).attr("data-id");
        ajaxGet("#(CPATH)/admin/article/doAddCategoryToMenu/" + id,function () {
            toastr.success("添加到菜单成功")
        })
    });

    $("#removeThumbnail").on("click", function () {
        $("#thumbnail").attr("src", "#(CPATH)/static/commons/img/nothumbnail.jpg");
        $("#articleThumbnail").val("");
    })


</script>
#end
#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            Banner管理
            <small>Banner Manage</small>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-lg-7">
                <div class="box box-primary">

                    <div class="box-header with-border">

                    </div>

                    <div class="box-body no-padding ">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th>banner</th>
                                <th>类型</th>
                                <th>文章ID</th>
                                <th>备注</th>
                                <th>排序</th>
                                <th>操作</th>
                            </tr>
                            #for(banner : banners)
                            <tr class="jp-actiontr">
                                <td>
                                    <img src="#(banner.img_url ?? '/static/commons/img/nothumbnail.jpg')"
                                         style="width: 100px;height: 50px">
                                </td>
                                <td>#(banner.type ??)</td>
                                <td>#(banner.article_id ??)</td>
                                <td>#(banner.remarks ??)</td>
                                <td>#(banner.order_number ??)</td>
                                <td>
                                    <a href="#(CPATH)/admin/article/banner/#(banner.id)" >编辑</a> |
                                    <a href="javascript:;" class="del-action red-action" data-id="#(banner.id)" >删除</a>
                                </td>
                            </tr>
                            #end
                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-sm-12">
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box -->
            </div>
            <div class="col-lg-5">
                <div class="box box-primary">
                    <div class="box-header ">
                        <h3 class="box-title"></h3>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form class="form-horizontal form-setting" autocomplete="off"
                          action="#(CPATH)/admin/article/doBannerSave"
                          id="form"
                          method="post">
                        <input type="hidden" name="banner.id" value="#(banner.id ??)">
                        <div class="box-body ">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">类型</label>
                                <div class="col-sm-9">
                                    <input type="input" class="form-control" placeholder="banner类型"
                                           value="#(banner.type ??)"
                                           name="banner.type">
                                    <p class="help-block">banner类型，api接口可通过参数type获取到相应的类型</p>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序</label>
                                <div class="col-sm-9">
                                    <input type="input" class="form-control" placeholder="此分类排序的序号"
                                           value="#(banner.order_number ??)"
                                           name="banner.order_number">
                                    <p class="help-block"> 越小的数字越靠前，只在同级分类上影响。 </p>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">文章ID</label>
                                <div class="col-sm-9">
                                    <input type="input" class="form-control"
                                           value="#(banner.article_id ??)" name="banner.article_id">
                                    <p class="help-block"> 文章ID，可去文章管理获取 </p>
                                </div>
                            </div>

                            <div class="form-group">
                                <!--<div class="box-header with-border ">-->
                                    <!--<h3 class="box-title">缩略图</h3>-->
                                <!--</div>-->
                                <label class="col-sm-2 control-label">Banner</label>
                                <div class="col-sm-9" style="margin-top: 8px;">
                                    <img src="#(banner.img_url ?? '/static/commons/img/nothumbnail.jpg')"
                                         style="width: 100%;height: 200px"
                                         id="thumbnail">
                                    <input type="hidden" value="#(banner.img_url ??)" name="banner.img_url"
                                           id="articleThumbnail">
                                </div>
                                <div class="col-sm-offset-2 col-sm-10" style="margin-top: 12px;">
                                    <button type="button" class="jp-image-browser btn btn-default btn-sm "
                                            for-src="thumbnail"
                                            for-input="articleThumbnail">选择图片
                                    </button>
                                    <a href="javascript:;" style="padding-left: 15px" id="removeThumbnail">移除</a>
                                </div>
                            </div>

                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="col-sm-offset-2 col-sm-10 submit-block">
                                <div class="box-submit">
                                    <button type="submit" class="btn btn-primary">提交</button>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </div>
        </div>

    </section>


</div>
#end
